home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_weap_carbgun_m.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
19KB
|
623 lines
# Jedi Knight Missions Cog Script
#
# WEAP_CARBGUN_M.COG
#
# WEAPON 20 Script - Carbonite Gun
#
# [YB & CYW] + [RF]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
model povModel=cbnv_m.3do local
model povModel_m=cbnv.3do local
model weaponMesh=cbng.3do local
keyframe thirdWhack=KKcarbf2.key local
keyframe povWhack=CbnVpst2.key local
keyframe mountAnim=BowVmnt.key local
keyframe dismountAnim=BowVdis.key local
keyframe povfireAnim=BowVpst1.key local
keyframe holsterAnim=kyhlstr.key local
#keyframe mountAnim=bryvmnt.key local
#keyframe dismountAnim=bryvdis.key local
#keyframe povfireAnim=bryvpst1.key local
#keyframe holsterAnim=kyhlstr.key local
sound fistSound=SwingFist01.wav local
template projPunch=+bigpunch local
sound outSound=pistout1.wav local
sound mountSound=df_bry_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound fireSound=cgunfire.wav local
sound failSound=weapfail.wav local
#sound powering=00industrialamb01.wav local
template projectile=+bryarbolt local
template cprojectile=+carbsparks local
template carboExplode=+sparks local
template csTpl=+CarboniteStem local
template c0Tpl=+CarboDebris_0 local
template c1Tpl=+CarboDebris_1 local
template c2Tpl=+CarboDebris_2 local
template c3Tpl=+CarboDebris_3 local
template c4Tpl=+CarboDebris_4 local
int debris local
thing player local
thing victim local
thing potential local
flex damageType local
flex damage local
flex dot local
flex maxDot local
flex soundPitch local
flex fireWait=0.5 local
flex holsterWait local
flex fireDelay=0.6 local
flex powerBoost local
flex autoAimFOV=30 local
flex autoAimMaxDist=5 local
int fireSize local
int weaponIndex local
int trackID=-1 local
int dummy=0 local
int mode local
int holsterTrack local
int smackTrack local
int powerChannel local
int i local
int j local
int k local
vector randVec local
thing statueList=-1 local
thing statueList2=-1 local
thing statueList3=-1 local
thing statueList4=-1 local
thing statueList5=-1 local
thing statueList6=-1 local
thing statueList7=-1 local
thing statueList8=-1 local
thing statueList9=-1 local
thing statueList10=-1 local
thing statueList11=-1 local
thing statueList12=-1 local
thing statueList13=-1 local
thing statueList14=-1 local
thing statueList15=-1 local
thing statueList16=-1 local
thing statueList17=-1 local
thing statueList18=-1 local
thing statueList19=-1 local
thing statueList20=-1 local
thing hitList=-1 local
thing hitList2=-1 local
thing hitList3=-1 local
thing hitList4=-1 local
thing hitList5=-1 local
thing hitList6=-1 local
thing hitList7=-1 local
thing hitList8=-1 local
thing hitList9=-1 local
thing hitList10=-1 local
int lastHit=-1 local
int lastHit2=-1 local
int lastHit3=-1 local
int lastHit4=-1 local
int lastHit5=-1 local
int lastHit6=-1 local
int lastHit7=-1 local
int lastHit8=-1 local
int lastHit9=-1 local
int lastHit10=-1 local
int hitCount=0 local
int hitCount2=0 local
int hitCount3=0 local
int hitCount4=0 local
int hitCount5=0 local
int hitCount6=0 local
int hitCount7=0 local
int hitCount8=0 local
int hitCount9=0 local
int hitCount10=0 local
int hitSide local
thing aiCarbonited local
template carboDummy=+CarboniteChar local
flex freezeradius=1.5 local
thing frozen local
message activated
message deactivated
message selected
message deselected
message autoselect
message fire
message timer
message damaged
message user0
end
# ========================================================================================
code
fire:
SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
if (mode == 0)
{
fireSize = 0.2;
call vire;
}
else
{
call mire;
}
return;
# ........................................................................................
vire: // Fire carbonite
player = GetSourceRef();
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
if (fireSize > GetInv(player, 90))
fireSize = GetInv(player, 90);
ChangeInv(player, 90, -1*fireSize);
// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 90) < 1.0)
{
PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
if(GetAutoSwitch() & 1)
{
// If out of ammo, switch to saber or fists.
if (GetWeaponPriority(player, GetWeaponBin(11), 0) > 0.0)
SelectWeapon(player, GetWeaponBin(11));
else if (GetWeaponPriority(player, GetWeaponBin(1), 0) > 0.0)
SelectWeapon(player, GetWeaponBin(1));
}
Return;
}
SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
while (fireSize > 0)
{
// Get random aiming error
randVec = VectorSet((Rand()-0.5)*2, (Rand()-0.5)*2, 0.0);
dummy = FireProjectile(player, cprojectile, fireSound, 8, '0.0135 0.1624 0.0', randVec, 4.0, 0x01, autoAimFOV, autoAimFOV*2);
SetThingCollideSize(dummy, 0.2);
fireSize = fireSize - 0.2;
}
hitSide = 1 - hitSide;
frozen = FirstThingInView(player, 45, freezeradius, 0x404);
// frozen = player;
// Check for things that are being exposed.
while (frozen != -1)
{
// Don't mess with inanimate objects.
if (!(GetActorFlags(frozen) & 0x100) && (frozen != player))
{
if (!(GetThingFlags(frozen) & 0x04)) // Don't freeze Magsealed actors (they're probably already frozen)
{
// Check for Carbonite immunity.
if (!(GetPhysicsFlags(frozen) & 0x2000000))
{
if (VectorDist(GetThingPos(frozen), GetThingPos(player)) < freezeradius)
// Double check LOS.
if (HasLOS(frozen, player))
{
for (i = 0; i < 10; i = i + 1)
{
if (hitList[i] == frozen)
{
hitCount[i] = hitCount[i] + 1;
lastHit[i] = hitSide;
if (hitCount[i] == 5)
{
// Is this a player?
if (GetThingType(frozen) == 10)
{
// print("Frozen Player!");
SkillTarget(frozen, player, 1035, 6.0);
}
else
{
// print("Frozen Actor!");
// Give the thing a chance to react.
if (SendMessageEx(GetThingClassCog(frozen), skill, 1035, 10.0, frozen, 0) != 17)
{
victim = frozen;
AISetMode(victim, 0x2000); // Disable the actor's AI.
AISetMoveThing(victim, victim); // Set the thing as it's own
// destination so it stops moving.
// Make victim invisible
SetThingFlags(victim, 0x14);
SetActorFlags(victim, 0x8000000);
aiCarbonited = CreateThing(carboDummy, victim);
AttachThingToThing(aiCarbonited, victim);
SetThingCollideSize(aiCarbonited, 0.01);
SetThingFlags(aiCarbonited, 0x04);
CaptureThing(victim);
// Note down what thing the carbonite statue is attached to.
SetThingUserData(aiCarbonited, victim);
j = -1;
// And note down the statue number.
for (k = 0; k < 20; k = k + 1)
{
if (statueList[k] == -1)
{
statueList[k] = aiCarbonited;
j = k;
k = 21;
}
}
// No slot found!
if (j == -1)
DestroyThing(aiCarbonited);
SendMessageEx(GetInvCog(player, 68), user0, victim, 0, 0, 0);
SetTimerEx(10.0, 101, victim, j); // Make an appointment for "Unthawing"
// Before going into the default handler (in WEAP_CARBGUN_M.COG)
// SendMessageEx(GetInvCog(GetLocalPlayerThing(), 140), user0, 1, 10.0, frozen, 0);
}
}
hitCount[i] = 0;
}
i = 20;
}
}
if (i < 20)
{
for (i = 0; i < 10; i = i + 1)
{
if (hitList[i] == -1)
{
hitList[i] = frozen;
hitCount[i] = 1;
lastHit[i] = hitSide;
}
}
}
}
}
}
}
frozen = NextThingInView();
}
// Cull any things that are no longer in the cone.
for (i = 0; i < 10; i = i + 1)
{
if (hitList[i] != -1)
if (lastHit[i] != hitSide)
hitList[i] = -1;
}
jkPlayPOVKey(player, povfireAnim, 1, 0x38);
// powerBoost = GetInv(player, 63);
// ChangeFireRate(player, fireWait/powerBoost);
Return;
# ........................................................................................
mire: // Butt punch (Hopefully neither Steve A. nor Chris K. will ever see this comment)
player = GetSourceRef();
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
FireProjectile(player, projPunch, fistSound, 44, '0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
jkPlayPOVKey(player, povWhack, 1, 0x38);
Return;
# ........................................................................................
activated:
player = GetSourceRef();
mode = GetSenderRef();
jkSetWaggle(player, '0.0 0.0 0.0', 0);
powerBoost = GetInv(player, 63);
if (mode != 0)
{
ActivateWeapon( player, 1.5, mode );
}
else
{
if (GetInv(player, 93) > 0.0)
{
PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
}
else
{
// Reset the list of things that are getting carbonite on them.
hitSide = 0;
for (i = 0; i < 10; i = i + 1)
hitList[i] = -1;
ActivateWeapon( player, 0.2, mode );
}
}
Return;
# ........................................................................................
deactivated:
player = GetSourceRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon( player, GetSenderRef() );
Return;
# ........................................................................................
selected:
player = GetSourceRef();
// Setup the meshes and models.
if (GetInv(player, 67) == 0.0)
jkSetPOVModel(player, povModel); // Kyle hand
else
jkSetPOVModel(player, povModel_m); // Mara Hand
jkSetWeaponMesh(player, weaponMesh);
SetArmedMode(player, 1);
// Play mounting sound.
PlayMode(player, 41);
PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
// Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
// The animation is held at the last frame after it is played.
trackID = jkPlayPOVKey(player, mountAnim, 0, 0x14);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
// Clear saber flags, and allow activation of the weapon
jkClearFlags(player, 0x5);
SetCurWeapon(player, GetWeaponBin(20));
SetMountWait(player, GetKeyLen(mountAnim));
Return;
# ........................................................................................
deselected:
player = GetSourceRef();
weaponIndex = GetSenderRef();
PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
jkPlayPOVKey(player, dismountAnim, 0, 18);
holsterWait = GetKeyLen(holsterAnim);
SetMountWait(player, holsterWait);
holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
SetTimerEx(holsterWait, 2, 0.0, 0.0);
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);
Return;
# ........................................................................................
autoselect:
player = GetSourceRef();
// If the player has the weapon
if(GetInv(player, GetWeaponBin(20)) != 0.0)
{
// If the player has ammo
if(GetInv(player, 90) != 0.0)
{
ReturnEx(150.0);
}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}
Return;
# ........................................................................................
damaged:
damageType = GetParam (1);
damage = GetParam(0);
victim = GetSenderRef();
// If this is impact, explosion or saber damage, kill the player.
if (BitTest(damageType, 0x15))
{
// CreateThing(carboExplode, victim);
debris = CreateThingAtPos(c0Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
debris = CreateThingAtPos(c1Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
debris = CreateThingAtPos(c2Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
debris = CreateThingAtPos(c3Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
debris = CreateThingAtPos(c4Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
for (i = 0; i < 20; i = i + 1)
{
if (statueList[i] != -1)
if (GetThingUserData(statueList[i]) == victim)
{
DestroyThing(statueList[i]);
statueList[i] = -1;
DestroyThing(victim);
i = 30;
}
}
ReturnEx(GetThingHealth(victim) * 10);
}
else
{
// Otherwise, no damage.
ReturnEx(0);
}
return;
# ........................................................................................
timer:
if (GetSenderId() == 2)
{
StopKey(player, holsterTrack, 0.0);
}
else
if (GetSenderId() == 3)
{
StopKey(player, smackTrack, 0.0);
}
else
if (GetSenderId() == 101)
{
victim = GetParam(0);
j = GetParam(1);
// Make actor visible
ClearThingFlags(victim, 0x14);
ClearActorFlags(victim, 0x8000000);
// Enable actor's AI
AIClearMode(victim, 0x2000);
AISetMoveThing(victim, player); // Set the thing moving again
ReleaseThing(victim);
if (j != -1)
{
// Destroy actor's carbonite dummy
DestroyThing(statueList[j]);
statueList[j] = -1;
}
}
Return;
# ........................................................................................
user0:
victim = GetParam(2);
AISetMode(victim, 0x2000); // Disable the actor's AI.
AISetMoveThing(victim, victim); // Set the thing as it's own
// destination so it stops moving.
// Make victim invisible
SetThingFlags(victim, 0x14);
SetActorFlags(victim, 0x8000000);
aiCarbonited = CreateThing(carboDummy, victim);
AttachThingToThing(aiCarbonited, victim);
SetThingCollideSize(aiCarbonited, 0.01);
SetThingFlags(aiCarbonited, 0x04);
CaptureThing(victim);
// Note down what thing the carbonite statue is attached to.
SetThingUserData(aiCarbonited, victim);
j = -1;
// And note down the statue number.
for (k = 0; k < 20; k = k + 1)
{
if (statueList[k] == -1)
{
statueList[k] = aiCarbonited;
j = k;
k = 21;
}
}
// No slot found!
if (j == -1)
DestroyThing(aiCarbonited);
SendMessageEx(GetInvCog(player, 68), user0, victim, 0, 0, 0);
SetTimerEx(GetParam(1), 101, victim, j); // Make an appointment for "Unthawing"
return;
end